<table width="100%"><tr><td width="20%">
<a href="../index.html">&lt; index</a><br />
<a href="index.html">&lt; 2. Console emulator</a><br />
<a href="console_offscreen.html">&lt; 2.4 Using off-screen consoles</a>
</td><td width="60%">
<p align="center">
=====================================<br />
2.4.1 Creating an offscreen console<br />
=====================================<br />
</p></td><td width="20%">
</td></tr></table>
<style type="text/css">
.code { color:#444444; background-color:#EEEEEE;}
pre { color:#444444; background-color:#EEEEEE;}
table.param td { border : 1px solid #000000; }
th { background-color: #44BBFF; color: #FFFFFF }
table.none td { border : 0 }
</style>
<p class="code"><pre>
C++ : TCODConsole::TCODConsole(int w, int h)
C   : TCOD_console_t TCOD_console_new(int w, int h)
Py  : console_new(w,h)
</pre></p>
You can create as many off-screen consoles as you want by using this function. You can draw on them as you would do with the root console, but you cannot flush them to the screen. Else, you can blit them on other consoles, including the root console. See <a href="console_blit.html">blit</a>. The C version of this function returns a console handler that you can use in most <a href="console_drawing.html">console drawing functions</a>.<br />
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>w,h</td><td>The console size.<br />0 &lt; w<br />0 &lt; h<br /></td></tr>
</table>
Example :<br />
Creating a 40x20 offscreen console, filling it with red and blitting it on the root console at position 5,5<br />
<p class="code"><pre>
C++ : TCODConsole *offscreenConsole = new TCODConsole(40,20);
      offscreenConsole->setBackgroundColor(TCODColor::red);
      offscreenConsole->clear();
      TCODConsole::blit(offscreenConsole,0,0,40,20,TCODConsole::root,5,5,255);
C   : TCOD_console_t offscreen_console = TCOD_console_new(40,20);
      TCOD_console_set_background_color(offscreen_console,TCOD_red);
      TCOD_console_clear(offscreen_console);
      TCOD_console_blit(offscreen_console,0,0,40,20,NULL,5,5,255);
Py  : offscreen_console = libtcod.console_new(40,20)
      libtcod.console_set_background_color(offscreen_console,libtcod.red)
      libtcod.console_clear(offscreen_console)
      libtcod.console_blit(offscreen_console,0,0,40,20,0,5,5,255)
</pre></p>
